//
//  LGOrderSportHeadView.m
//  HeartDiseaseManage
//
//  Created by 1234 on 2023/11/6.
//

#import "LGOrderSportHeadView.h"

@interface LGOrderSportHeadView()
/**   */
@property (nonatomic , strong)UIImageView *statusView;
/**   */
@property (nonatomic , strong)UILabel *statusLabel;
/**   */
@property (nonatomic , strong)UIView *lineView;
/**   */
@property (nonatomic , strong)UILabel *titleLabel;
/**   */
@property (nonatomic , strong)UIView *patientView;
/**   */
@property (nonatomic , strong)UIButton *titleBtn;
/**   */
@property (nonatomic , strong)UILabel *nameLabel;
/**   */
@property (nonatomic , strong)UILabel *ageLabel;

@end

@implementation LGOrderSportHeadView

- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        [self createSubView];
    }
    return self;
}

-(void)setTitle:(NSString *)title{
    _title = title;
    self.titleLabel.text = title;
}

-(void)setStatus:(NSString *)status{
    _status = status;
    //预约详情 -- 10：待支付 20：已取消 30：待接诊 31：咨询中   40 已完成  41：已爽约  42 ：未接通  50：已退款
    //订单详情 -- 1：已完成 3：已退款
    if([status isEqualToString:@"30"]){
        //未就诊
        self.statusView.image = [UIImage imageNamed:@"订单详情-待接诊"];
        
    }else if ([status isEqualToString:@"20"]||[status isEqualToString:@"50"]||[status isEqualToString:@"3"]){
        //已取消、已逾期、已过期、未支付、已退款
        self.statusView.image = [UIImage imageNamed:@"订单详情-已退款"];
        
    }else{
        //已就诊、已完成
        self.statusView.image = [UIImage imageNamed:@"订单详情-已完成"];
    }
}

-(void)setStatusName:(NSString *)statusName{
    _statusName = statusName;
    self.statusLabel.text = statusName;
}

-(void)setPatientDic:(NSDictionary *)patientDic{
    _patientDic = patientDic;
    self.nameLabel.text = LGNSString(patientDic[@"realname"]);
    NSString *age = LGNSString(patientDic[@"age"]);
    age = (age.length>0)?[NSString stringWithFormat:@"%@岁",age]:@"";
    self.ageLabel.text = [NSString stringWithFormat:@"%@ %@",patientDic[@"gender"],age];
}



#pragma mark
#pragma mark ====> 创建控件

-(void)createSubView{
    [self addSubview:self.statusView];
    [self.statusView addSubview:self.statusLabel];
    [self addSubview:self.lineView];
    [self addSubview:self.titleLabel];
    [self addSubview:self.patientView];
    [self.patientView addSubview:self.titleBtn];
    [self.patientView addSubview:self.nameLabel];
    [self.patientView addSubview:self.ageLabel];
    [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.patientView).offset(viewPix(16));
        make.top.equalTo(self.titleBtn.mas_bottom).offset(viewPix(15));
    }];
    [self.ageLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.nameLabel.mas_right).offset(viewPix(15));
        make.centerY.equalTo(self.nameLabel);
    }];
}

-(UIImageView *)statusView{
    if(!_statusView){
        _statusView = [[UIImageView alloc]initWithFrame:CGRectMake(viewPix(20), viewPix(16), Screen_W-viewPix(40), viewPix(83))];
    }
    return _statusView;
}

-(UILabel *)statusLabel{
    if(!_statusLabel){
        _statusLabel = [UILabel lableWithText:@"" colorString:@"#FFFFFF" textFont:LGFontWeight(18, UIFontWeightSemibold) textAlignment:NSTextAlignmentLeft lines:1];
        _statusLabel.frame = CGRectMake(viewPix(35), viewPix(31), viewPix(100), viewPix(20));
    }
    return _statusLabel;
}

-(UIView *)lineView{
    if(!_lineView){
        _lineView = [[UIView alloc] initWithFrame:CGRectMake(viewPix(16), kMaxY(self.statusView.frame)+viewPix(21), 4, viewPix(14))];
        _lineView.backgroundColor = [UIColor colorWithString:@"#77D4C6"];
        _lineView.cornerRidus = 2;
    }
    return _lineView;
}

-(UILabel *)titleLabel{
    if(!_titleLabel){
        _titleLabel = [UILabel lableWithText:@"" colorString:@"#333333" textFont:LGFontWeight(16, UIFontWeightMedium) textAlignment:NSTextAlignmentLeft lines:1];
        _titleLabel.frame = CGRectMake(viewPix(32), kMaxY(self.statusView.frame)+viewPix(17), viewPix(200), viewPix(22));
    }
    return _titleLabel;
}

-(UIView *)patientView{
    if(!_patientView){
        _patientView = [UIView shadowViewWithColor:@"#B2BDC7" offset:CGSizeMake(0, 2) opacity:0.15 radius:8];
        _patientView.frame = CGRectMake(viewPix(16), viewPix(156), Screen_W-viewPix(32), viewPix(90));
        _patientView.backgroundColor = [UIColor whiteColor];
    }
    return _patientView;
}

-(UIButton *)titleBtn{
    if(!_titleBtn){
        _titleBtn = [UIButton buttonWithTitle:@"用户信息" titleFont:LGFontWeight(16, UIFontWeightMedium) textColor:@"#333333" imageName:@"订单详情-就诊人信息"];
        _titleBtn.frame = CGRectMake(viewPix(16), viewPix(16), viewPix(250), viewPix(23));
        _titleBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
        _titleBtn.titleEdgeInsets = UIEdgeInsetsMake(0, viewPix(12), 0, 0);
        _titleBtn.userInteractionEnabled = NO;
    }
    return _titleBtn;
}

-(UILabel *)nameLabel{
    if(!_nameLabel){
        _nameLabel = [UILabel lableWithText:@"" colorString:@"#333333" textFont:LGFont(16) textAlignment:NSTextAlignmentLeft lines:1];
    }
    return _nameLabel;
}

-(UILabel *)ageLabel{
    if(!_ageLabel){
        _ageLabel = [UILabel lableWithText:@"" colorString:@"#666666" textFont:LGFont(15) textAlignment:NSTextAlignmentLeft lines:1];
    }
    return _ageLabel;
}

@end
